package com.homegoods.home.item;

import android.text.SpannableStringBuilder;

import com.alibaba.android.arouter.launcher.ARouter;
import com.homegoods.aroutercomment.ARouterPath;
import com.homegoods.home.R;
import com.homegoods.home.model.SearchProductListModel;
import com.homegoods.resource.util.Utils;
import com.kedll.library.mvp.BaseItem;

public class SearchProductItem extends BaseItem<SearchProductListModel> {

    public SearchProductItem(SearchProductListModel data) {
        super(data);
        //点击事件，点击后根据商品id跳转到商品详情页
        setOnClickListener(v -> {
            ARouter.getInstance()
                    .build(ARouterPath.PATH_GOODS_DETAIL)
                    .withString("sid", data.getId())
                    .navigation();
        });
    }

    @Override
    public int getLayout() {
        return R.layout.home_item_search_product_list;
    }

    public String getProductName() {
        return getData().getProductName();                  //商品名称
    }

    public SpannableStringBuilder getMinPrice() {
        return Utils.getPrice(getData().getMinPrice());     //商品价格（最低价）
    }

    public String getPic() {
        return getData().getPic();                          //商品图片
    }

    public String getCityName() {
        return getData().getCityName();                     //发货地址
    }

    public String isDistributionType() {
        return getData().isDistributionType();              //是否包邮
    }

}
